<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="page-header">
							<h1>
							审核 <?php echo $ac->name ;?> 活动
							</h1>
</div>

<div class="row">
	<div class="col-xs-12">
		  <div class="row">
			   <div class="col-xs-12">
													<div class="widget-box">
														<div class="widget-header widget-header-small">
															<h5 class="lighter">查询</h5>
														</div>

														<div class="widget-body">
															<div class="widget-main">
																<?php $this->renderPartial("_searchform",array('classRooms'=>$classRooms,'major'=>$major)); ?>
															</div>
														</div>
													</div>
													
			</div>
			</div>	
				<div class="row">
				   <div class="col-xs-12">
				  <div class="widget-box">
														<div class="widget-header widget-header-small">
															<h5 class="lighter">共检索出 <?php echo $total; ?>条结果 </h5>
														</div>

														<div class="widget-body">
															<div class="widget-main">
						<div class="table-responsive">
										<form id="activity">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														<th class="center">
															<label>
																<input type="checkbox" class="ace">
																<span class="lbl"></span>
															</label>
														</th>
														<th>学生姓名</th>
														
														<th  >班级</th>
														
														<th  >年级</th>
														<th  >专业</th>
														<th  >添加内容</th>
													    <th>
															<i class="icon-time bigger-110 hidden-480"></i>
															添加时间
														</th>
														
														<th>操作</th>
													</tr>
												</thead>

												<tbody>
												<?php
												  foreach($stuAcs as $s){
													  $realName = $s->stuinfo?$s->stuinfo->realName:'未添加';
													  $class = $s->stuinfo?$s->stuinfo->classRoom:'未添加';
													  $grade = $s->stuinfo?$s->stuinfo->grade:'未添加';
													  $major = $s->stuinfo?$s->stuinfo->major:'未添加';
													 echo '
													<tr stu-activity-id = "'.$s->stuActivityId.'">
													    <td class="center">
															<label>
																<input type="checkbox" class="ace" name="l" value="'.$s->stuActivityId.'">
																<span class="lbl"></span>
															</label>
														</td>
														<td>
															<a href="#">'.$realName.'</a>
														</td>
														
														<td  >'.$class.'</td>
														
														<td>'.$grade.'</td>
														<td>'.$major.'</td>
														
														
														<td  >
														<span display-detail-id="'.$s->stuActivityId.'" style="display:none;">'.$s->detail.'</span>
															<button class="btn btn-sm btn-info" detail-id="'.$s->stuActivityId.'">
																详情
															</button>
														</td>
														<td>'.$s->addtime.'</td>
														

														
														<td>
															<div >
												              
																<a target="_blank" >
																<button class="btn btn-xs btn-warning" data-rel="tooltip" data-original-title="不通过" thumbs-down = "'.$s->stuActivityId.'" >
																	<i class="icon-thumbs-down bigger-120"></i>
																</button>
																</a>
																<a target="_blank" >
																<button class="btn btn-xs btn-success" data-rel="tooltip" data-original-title="通过" thumbs-up = "'.$s->stuActivityId.'">
																	<i class="icon-thumbs-up bigger-120"></i>
																</button>
																</a>
															</div>

														</td>
													</tr>';
												  }
                                                   ?>
												</tbody>
											</table>
										</div><!-- /.table-responsive -->
								<div class="col-xs-12" style="text-align:center">
										     <?php 
											 $this->widget('CLinkPager',array( 
													'htmlOptions'=>array('class'=>'pagination'),
													'cssFile'=>false,
													'header'=>'',    
													'firstPageLabel' => '首页',    
													'lastPageLabel' => '末页',    
													'prevPageLabel' => '上一页',    
													'nextPageLabel' => '下一页',    
													'pages' => $pages,    
													'maxButtonCount'=>13    
												)    
											);    
												
										?>
							       </div>
								<p>
								  <button class="btn btn-lg btn-success" id="muti-up">
									<i class="icon-thumbs-up"></i>
										批量通过										
								  </button>
								  <button class="btn btn-lg btn-warning" id="muti-down">
									<i class="icon-thumbs-down"></i>
										批量否定										
								  </button>
								</p>
								</form>
										</div>
									</div>
								</div>	
							</div>			
							</div>
						</div>
					</div>			


<script type="text/javascript">

			jQuery(function($) {
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
				$('[detail-id]').on("click",function(){
					var id = $(this).attr('detail-id');
					bootbox.alert($("[display-detail-id = "+id+"]").html(),function(){
						
						
					});

				  return false;
				   
				});
				
				 //在审核的过程中添加备注信息
			  $("[thumbs-down]").on('click',function(){
				  var id = $(this).attr('thumbs-down');
				  
				  bootbox.prompt({
					  title:"添加备注",
					  value: "同学，您的这条记录有误",
					   
					  callback: function(result) {                
						  if (result === null) {                                             
							                              
						  } else {
							$.post('<?php echo Yii::app()->createUrl('activity/addcomment'); ?>',{'stuActivityId':id,'comment':result},function(data){
								data = $.parseJSON(data);
								if(data){
									bootbox.alert(data['msg'],function(){
										if(data['code'] == '200'){
										$('[stu-activity-id = '+id+']').fadeToggle('800','linear',function(){
									       $(this).remove();
										});
									   
									}
							       
								   });
									
									
						        }else{
									bootbox.alert('额额，好像服务器君出错了！！',function(){
										
									});
									
								}
								
								
							});                       
						  }}
				  });
				   return false;
				  
			  });
			// 通过一个学生
			$('[thumbs-up]').on('click',function(){
				 var id = $(this).attr('thumbs-up');
				  $.post('<?php echo Yii::app()->createUrl('activity/passone'); ?>',{'stuActivityId':id},function(data){
                      if(data){
						  data = $.parseJSON(data);
						  bootbox.alert(data['msg'],function(){
						      if(data['code'] == '200'){
										$('[stu-activity-id = '+id+']').fadeToggle('800','linear',function(){
									       $(this).remove();
										});
									   
									}
						  });
						  
						  
					  }else{
						  bootbox.alert('抱歉，服务器君好像出错了',function(){});
					  }					  
					  
				  });
				  return false;
				
			});
			
			 $('#muti-up').on('click',function(){
				  bootbox.confirm('确定要将这些学生通过审核吗？',function(result){
					  if(result){
						  var stus = $('#activity').serialize();
						  $.post('<?php echo Yii::app()->createUrl('activity/passmuti'); ?>',{'stus':stus},function(data){
								console.log(data);
								data = $.parseJSON(data);
								if(data){
									bootbox.alert(data['msg'],function(){
										for(i in data['successArray']){
										$('[stu-activity-id = '+data['successArray'][i]+']').fadeToggle('500','linear',function(){
									       $(this).remove();
										});
									  }
							        });
									
									
						        }else{
									bootbox.alert('额额，好像服务器君出错了！！',function(){
										
									});
									
								}
								
								
							});    
						  
					  }
				  });
				  
				  return false;
				  
			  });
			  $('#muti-down').on('click',function(){
				  bootbox.confirm('确定要将这些学生不通过审核吗？',function(result){
					  if(result){
						    var stus = $('#activity').serialize();
					      $.post('<?php echo Yii::app()->createUrl('activity/unpassmuti'); ?>',{'stus':stus},function(data){
								console.log(data);
								data = $.parseJSON(data);
								if(data){
									bootbox.alert(data['msg'],function(){
										for(i in data['successArray']){
										$('[stu-activity-id = '+data['successArray'][i]+']').fadeToggle('500','linear',function(){
									       $(this).remove();
										});
									  }
							        });
									
									
						        }else{
									bootbox.alert('额额，好像服务器君出错了！！',function(){
										
									});
									
								}
								
								
							});    
						  
					  }
				  });
				  
				  return false;
				  
			  });
			
				
			})
		
</script>